<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加导航</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  
    {include file="public/css"}
    {include file="public/js"}
</head>
<body>

<div class=""  style="padding:20px">

<form class="layui-form"  method="post">
<input type="hidden"  name="pid"  value="{$Request.param.pid}">

              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"> 导航标题</label>
                <div class="layui-input-inline">
                  <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"> 导航URL</label>
                <div class="layui-input-inline">
                  <input type="text" name="url"  autocomplete="off" placeholder="控制器/方法名" class="layui-input" >
                </div>
               <div class="layui-form-mid layui-word-aux"></div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">排序</label>
                <div class="layui-input-inline">
                  <input type="text" name="sort" lay-verify="sort" autocomplete="off" placeholder="" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">图标</label>
                <div class="layui-input-inline">
                  <input type="text" name="icon" lay-verify="icon" autocomplete="off" placeholder="" class="layui-input">
                </div>
              </div>


              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">状态</label>
                <div class="layui-input-inline">
                <input type="checkbox" class="status"  name="status" lay-skin="switch"  lay-filter="switchTarget" lay-text="开启|关闭">
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"></label>
                <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="form">确 定</button>
                </div>
              </div>


</form>
</div>


<script>
layui.use(['element', 'layer','form'], function(){
   var  element = layui.element, layer = layui.layer,form = layui.form;
//监听提交
  form.on('submit(form)', function(data){
    $.post("{:url('nav/add')}",$("form").serialize(),function(json){
          if(json.code == 0){
      
  //添加数据成功，关闭弹出窗之前，刷新列表页面的数据
             layer.msg(json.msg);
             setTimeout(function(){
                  var index = parent.layer.getFrameIndex(window.name); //获取窗口索引      
                // parent.window.location.reload();
                parent.layer.close(index);       
             },2000);
   
             

          }else{
            layer.msg(json.msg);
          }
    });
   return false;  //阻止表单跳转使用提供layer 提交
  });
});

</script>

</body>

</html>